Repository navigation
fix(cluster): DevNet and production no longer share a pair on one Mac - #1846
Merged
Merged
Conversation
On a Mac with both the production app (darkbloom) and the DevNet app (darkbloom-dev), both builds used one set of cluster state: the pairing store, the setup and service folder, the device folder, the saved setups, the observability files, the supervision files, the pair prefix cache, the temporary-directory locks and the ports on the cable. Each build also took every io.darkbloom.cluster-service.* login job for its own. DevNet's status read production's pair, its update asked production's cluster service to restart, and `darkbloom-dev cluster pair --forget` or `cluster stop --service` removed production's login job (0.10.9's known limitation). Every cluster path now derives from the build's own folders (BuildEnvironment.installDirectory and configDirectory) through ClusterUserPaths, which carries the build; the pairing store's default moves to ProviderCore (ClusterPairingStore.default(home:environment:)), and the library's observability defaults take an install folder. Two identity fields name the rest: clusterServiceLabelPrefix (DevNet's login jobs are io.darkbloom.cluster-service.dev.<12 hex>) and clusterPortOffset (DevNet's cable ports are production's plus 10, ClusterCablePorts). Locks, the pair prefix cache root and the placement helper's default probes follow the build. ClusterServiceAgentPlan.isOwnAgent decides whose a login job is, so each build lists, replaces and removes only its own; an older DevNet app's job of production's shape is DevNet's when its program is in ~/.darkbloom-dev, and production never takes it. Production's paths, label, locks and ports are byte for byte what they were; a test pins them. DevNet starts unpaired and copies nothing: update both Macs, then pair again with `darkbloom-dev cluster`. Uninstalling one app removes only its own pairing, setup and cluster service and keeps the cable port setup while the other app is installed; the shared-folder special cases in the uninstall are gone. The models, the cluster model store, the cable port setup and the orphan sweep stay shared on purpose. Tests: ClusterInstallIsolationTests (production pinned; every build's paths, labels, locks and ports disjoint; real pairing ceremonies in private homes; update requests and service files; screen locks; the placement helper; a source check that no provider call pairs, probes or listens on the library's production ports, which caught the guided pairing still on 47421), the login-job and uninstall crossings both ways. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s build's names From the independent refactor pass over the DevNet/production isolation: - M1: the cable port setup stays shared, but each build now keeps its own record of how to undo it. Uninstalling the app that set a port up, while the other stays, deleted the bridge slot and the services that setup turned off, so the remaining app could only partly undo it. A port the other app set up is now adopted with what that app's record says the setup changed (ClusterLinkRepair.otherInstallsIsolationEntries, adoptionEntry): read from the other app's record and never written there. Red first in ClusterLinkChecks (1 of 2543 failed without it); ClusterInstallIsolationTests covers the read and the uninstall in CI. - ClusterUserPaths.init() is public only for the running build. - `cluster pair` names this build's command for the other Mac (DevNet's said `darkbloom cluster pair`, which now pairs production on its own port). - The GLM prefill frame-timing switch is read from the worker's own install folder. - ClusterIncidentLog.files, unused since the uninstall rework, is gone. - Docs: each app's pair has its own device lease, so two pairs at once share the Macs' memory; what is shared on purpose; doc comments that named only production's paths. - Tests that assumed a production test build (a label fixture, a hard-coded ~/.darkbloom, an unstamped incident file) now pass in a DevNet test build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… --remove asks From the independent review of #1846: - Two pairs on one Mac: each build kept its own device lease, so a DevNet pair could start beside production's and push it out of memory. Every build's device scope (a pair's owner session, a member's preparation, a GLM calibration) now also takes one lock all builds share, ~/Library/Application Support/Darkbloom/cluster-native-device.lock: flock only, in no build's folder (ClusterMachineDeviceLock, ClusterUserPaths.machineDeviceLock). It is taken after the build's own lease, so a second process of the same build is still refused by its lease; the other build's start is refused with a line naming the app that holds the Mac and its stop command. Production's paths, label, locks and ports are unchanged. Red first in ProcessChecks' device exclusion check (a second build's scope started beside the first's); ClusterInstallIsolationTests covers both builds' real paths and the refusal, and a source check that every device scope passes the lock. - Model copies: a copy short of disk reclaimed every staging folder in the store both apps share, the other app's copy under way included. Staging is named per build (production's .darkbloom-incoming-<digest> unchanged, DevNet's .darkbloom-incoming-dev-<digest>), and a copy reclaims only its own build's abandoned staging. Red first in ClusterModelProvisioningChecks (3 of 169). - `cluster link --remove` beside the other app that still holds the port in its link record (read only) names that app and asks at a terminal, even with --yes; without a terminal, or with --json, it changes nothing. Red first in ClusterPairCommandsTests (4 issues). - Docs and the changelog fragment say all three. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The final re-review of #1846 found two gaps in the shared GPU lock: 1. A start refused for the lock counted as a failing part, so after three the leader served the pair on its local API for an hour, even once the other app had stopped. - Every refusal says "holds this Mac's GPU" (ClusterMachineDeviceLock.isRefusal), and ClusterApprovalCheck.memberQuickEnds never counts it. - The cluster service doesn't start its part into a hold (heldByAnotherBuild probes the lock shared and checks its own lease). The part waits, says so once, and is named in the status's heldBack, so the leading Mac waits too. - The part starts on the first tick after the hold ends, with its backoff, quick ends and any .failing set-aside cleared (blockerCleared). A refused end seeds the same wait. This works in both directions. - A start retries a held lock for up to 100 ms, so the other build's probe never refuses it. 2. Production 0.10.9/0.10.10 takes no lock. A build other than production's now treats production serving as a hold, read only and never through production's locks (ClusterMachineDeviceLock.productionServingHere): - a serving process of production's own app (darkbloom start, cluster link-follower, worker owner, worker, run from ~/.darkbloom), from the process table; - or production's cluster service published within two minutes that its pair serves here (service-status.json), which also covers the seconds production's part restarts for an update. Its cluster service also stops a running part when production starts serving (both at login). Production builds get no guard: production wins by default. Also from the review: - A DevNet build is never told to stop production. Production blocked by DevNet is told `darkbloom-dev cluster stop`. - The lock moves out of the desktop app's folder, to ~/Library/Application Support/io.darkbloom.cluster/native-device.lock. Tests, red first: - ClusterInstallIsolationTests: refusals never count; DevNet refuses beside production's worker process; the process and status rules. - ClusterApprovalServiceStartTests, on the real service loop: refused starts never count and the lock's release starts the part; a part waits while the other app holds the real lock; a part steps aside for production. - ProcessChecks device exclusion: the other holder, and a probe waited out. Docs: agent-setup (STOP: never stop production from DevNet), two-mac-cluster, troubleshooting, architecture/inference, and the changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
jonathan308
added a commit
that referenced
this pull request
Nov 6, 2026
fix(cluster): production guard follow-ups from #1846's final review
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a Mac with both the production app (
darkbloom) and the DevNet app (darkbloom-dev), the two shared every piece of cluster and pairing state. 0.10.9 ships this as a known limitation: the DevNet app can read production's pair state, restart production's cluster service, anddarkbloom-dev cluster pair --forgetcan remove production's login job.With this PR each build keeps its own cluster and pairing state. Production's paths, launchd label shape, lock names and cable ports are byte for byte what they were, and a test pins them. Only these stay shared, on purpose:
Inventory: 10 kinds of state were shared. Compiled as a DevNet build, the original code resolved 12 of 12 checked paths, labels, locks and ports to production's (RED below). The independent review found two more: the GPU and model-copy staging (rows 11 and 12).
~/.darkbloom/cluster-pairing~/.darkbloom-dev/cluster-pairing~/.darkbloom/cluster-setup~/.darkbloom-dev/cluster-setuplink-fix.sh~/.darkbloom/cluster-device~/.darkbloom-dev/cluster-device~/.config/darkbloom/clusters~/.config/darkbloom-dev/clusters~/.darkbloom/cluster/~/.darkbloom-dev/cluster/~/.darkbloom/cluster-member-health.json,cluster-supervisor.json~/.darkbloom-dev~/Library/Caches/darkbloom/cluster-prefix-v1~/Library/Caches/darkbloom-dev/cluster-prefix-v1cluster,cluster stop --service,pair --forgetanduninstalllist, replace or removeio.darkbloom.cluster-service.<12 hex>; every build took every such job as its own…f19aa32ccffdfor/Users/someone/.darkbloom/Darkbloom.app, pinned)io.darkbloom.cluster-service.dev.<12 hex>; each build touches only its own jobsdarkbloom-cluster-{console,exchange,control}.lockdarkbloom-dev-cluster-…locknative-device.lease~/Library/Application Support/io.darkbloom.cluster/native-device.lock.darkbloom-incoming-<digest>; a copy short of disk reclaimed every one.darkbloom-incoming-dev-<digest>; reclaims only its ownShared on purpose:
Before
flowchart LR P["darkbloom (production app)"] D["darkbloom-dev (DevNet app)"] subgraph Shared["One set of cluster state"] S1["~/.darkbloom/cluster-pairing, cluster-setup, cluster-device, cluster/"] S2["~/.config/darkbloom/clusters"] S3["LaunchAgents io.darkbloom.cluster-service.*: each build lists, replaces and removes all"] S4["cable ports 47420-47424 and 52420, temp-dir locks, prefix cache"] end P --> S1 & S2 & S3 & S4 D --> S1 & S2 & S3 & S4After
flowchart LR P["darkbloom (production app)"] D["darkbloom-dev (DevNet app)"] subgraph Prod["Production: unchanged"] P1["~/.darkbloom/cluster-*, ~/.config/darkbloom/clusters"] P2["io.darkbloom.cluster-service.HASH"] P3["ports 47420-47424 and 52420, darkbloom-cluster-*.lock"] end subgraph Dev["DevNet: its own"] D1["~/.darkbloom-dev/cluster-*, ~/.config/darkbloom-dev/clusters"] D2["io.darkbloom.cluster-service.dev.HASH"] D3["ports 47430-47434 and 52430, darkbloom-dev-cluster-*.lock"] end G["One GPU lock: ~/Library/Application Support/io.darkbloom.cluster/native-device.lock (one pair per Mac)"] M["Shared on purpose: models, cluster model store, cable port setup, orphan sweep"] P --> P1 & P2 & P3 D --> D1 & D2 & D3 P --> G D --> G P -.-> M D -.-> MHow
ClusterUserPathscarries the build and derives every cluster folder fromBuildEnvironment.installDirectory/configDirectory. Its public init is for the running build only.ClusterPairingStore.default(home:environment:)(ProviderCore) replaces the library's home-only default. The library's observability defaults take an install folder.provider-swift/identity/provider-identity.json:clusterServiceLabelPrefixandclusterPortOffset(0 / 10 / 20).ClusterCablePortsnames every cable port of a build. A source test fails on any provider call that pairs, probes or listens with the library's production defaults.ClusterServiceAgentPlan.isOwnAgent(fileName:program:environment:home:)decides whose a job is. A job of production's shape stays production's, unless its program is in another build's folder (an older DevNet app's job).ClusterServiceAgent.installedLabels/install/uninstall/statustake an environment and touch only that build's jobs.ClusterMachineDeviceLock(DarkbloomClusterProcess) is an empty owner-only file in a folder no app or build owns (io.darkbloom.cluster, created 0700), flock only.ClusterDeviceExclusion/ClusterDeviceLeasetake it after the build's own lease, so a second process of the same build is still refused by its lease, as before.ClusterUserPaths.machineDeviceLock: a pair's owner session (ClusterWorkerOwnerService.serveKeyed), member preparation, native member prepare, and the GLM calibration's three. A source test guards new call sites.The production Darkbloom on this Mac holds this Mac's GPU for its pair (or a model check), and two pairs don't fit one Mac's memory: this pair starts by itself once production's stops. Production serves here: ask its owner before stopping it.A DevNet user or agent is never told to stop production; production blocked by DevNet is tolddarkbloom-dev cluster stop.holds this Mac's GPU(ClusterMachineDeviceLock.isRefusal).ClusterApprovalCheck.memberQuickEndsnever counts such an end, so it can't add up to the 3 quick ends that set the pair aside as.failing(60 minutes on the leader's local API).ClusterMachineDeviceLock.heldByAnotherBuildprobes the lock shared (released at once) and checks that this build's own lease is free. While held, the part waits (ClusterOtherAppHold), says so once, and the status'sheldBacknames the holder, so the leading Mac waits too..failingset-aside cleared (blockerCleared). A refused end (the other app won a race) seeds the same wait. This works the same in both directions.ClusterDeviceExclusion.machineLockTries), so a probe never refuses it.ClusterMachineDeviceLock.productionServing).~/.darkbloom/that isdarkbloom start …(single-Mac serving or a pair's part),darkbloom cluster link-follower, the worker owner or the native worker (ClusterOrphanReaper.role).The production Darkbloom on this Mac holds this Mac's GPU: it is serving (process N) …(ClusterMachineDeviceLock.otherHolder, checked once the lock is held), and its service waits as above.otherHolderis nil): production wins by default, and from 0.10.11 the lock covers it.ClusterModelStore.stagingPrefix), and a copy short of disk reclaims only its own build's abandoned staging.cluster link --remove(review fix). When the other app still holds the port in its link record (ClusterLinkRepair.otherInstallsUsingCable, read only),--removenames that app and asks at a terminal, even with--yes. Without a terminal, or with--json, it changes nothing.Plan.cableKeptFor), so it asks for no password.ClusterLinkRepair.otherInstallsIsolationEntries,adoptionEntry), so the app uninstalled last can still undo it all.cluster pairhint.Migration: what a DevNet user sees once
darkbloom-dev clustershows the Mac as not paired. Update the DevNet app on both Macs, then rundarkbloom-dev clusteron both and pair again. Nothing is copied from production.~/.darkbloom-dev) is recognised as DevNet's, and the new DevNet code replaces or removes it. Production never touches it.darkbloom clustersays the Secure Enclave key changed and offers Pair again (the existing flow).Validation
Head
350e24789aondev06eefcbcd9, Xcode 27.2, on a Mac that serves production. Builds ran atnice -n 19with no debug info and no index store, under a watchdog that stops at 15 GiB free and pauses for M5U-QUIET. Every test run used a temporaryHOME(CFFIXED_USER_HOME). Nodarkbloomcommand was run, and no port 8000 or 47420–47423 was bound.Red first, for every finding:
ClusterOnboardingLive.swift:566ClusterLinkChecks: 1 of 2543 failedcableUndoSurvivesTheOtherBuildsUninstall)ProcessChecksdevice-exclusion check: "A second build's device scope started beside the first build's"devicesAreLockedAcrossBuilds(both builds' real paths and the refusal text) andeveryDeviceScopeTakesTheMachineLock(6 call sites)ClusterModelProvisioningChecks(a CI runner): 3 of 169 failedlink --removewith no warningClusterPairCommandsTests: 4 issuesClusterApprovalServiceStartTests), member refused by a held GPU lock: both refusals in 20 s counted (quick ends 2, the backoff growing), and the part never started. Part beside the other app's real lock: started on the held GPU. Unit: 3 refusals gave a count of 3.heldBack, starts within seconds. Count 0.devnetRefusesBesideAnOlderProductionsWorker). DevNet's lock ignored production's published "pair serves here". A running DevNet part kept running when production started (service loop).ProcessChecksdevice exclusion: "A device scope started beside a build that takes no lock".ProcessChecksdevice exclusion without the retry: refusedSwift tests, both flavours (CPU only). The filter is the 32 suites the change reaches, plus the member/native-pair and GLM calibration suites the review fixes touch (39 patterns), plus
SoloStepsStickTestsandClusterServicePartStartCacheTestsfor this round.ClusterMemberServeLoopTests(2-second negotiation windows), which failed while other builds kept the Mac's load average at 25–31. On its own the suite passed 11/11 on three of five reruns (load 11–31); the other two failed only those timing tests. They take no device scope, and the same two also fail on unchangeddev.ClusterInstallIsolationTestspasses 17/17, the service-start suite passes with the three new service-loop tests, and so do the agent, uninstall, observability and planner suites. 50 tests fail: the same 50 as onacb63c5e8a.dev(06eefcb) built as DevNet, same filter: it fails the same 47 tests asked about, plus the same three others (the onboarding-command text test and the two timing tests), plus one more this PR fixes (diagnosticsReportCarriesTheObservabilitySection). So 51 fail ondevand 50 on the head, and no failure is new on the head.darkbloom …,Darkbloom.appin the update fixtures, thedarkbloom/kv3anddarkbloom/cluster-prefix-v1roots. Plainswift testbuilds as DevNet on this branch (Package.swiftdefaults to dev); CI builds as production.Check runners (plain swiftc), on the head:
350e24789a(the runners that compile this round's files):ClusterInstalledSessionChecks(it caught a closure that wasn't@Sendablebefore the SwiftPM build did),ClusterPairingChecks,ClusterModelProvisioningChecks, libsProcessChecks(device exclusion 13/13),RemoteChecks,SSHChecks,LinkWorkerChecks,LinkControlChecks,ObservabilityChecks, and the worker'sQualificationChecks(80 tests).acb63c5e8a:ClusterLinkChecks(2543/2543),SecurityChecks.ClusterConfigurationChecks,ClusterConsoleChecksandClusterDiagnosticsChecksfail with exactly the errors they already have ondev(see Limitations).081f108031:ClusterOnboardingChecks(a CI runner) 1829/1829, plus Supervision, Pairing, Placement, Control and libs Placement, Observability, Prelude. The review fixes don't change their sources.Other checks:
scripts/test-provider-identity.py11/11;make changelog-check,docs-check(208 OK),docs-impact-checkOK;check-provider-weak-imports.pyOK on the builtdarkbloom;check-date-comparisons.pyOK (1941 files);350e24789awith this push. On081f108031it was green apart from the two Vercel deployments, which also fail on fix(cluster-api): end a rejected stream with the single-Mac error chunk before the pair retires #1839 and provider: release each chunk of a chunked file read #1836.Not run: the full provider suite with GPU/MLX lanes (this Mac serves production), and a hardware pair with both apps installed.
Limitations
~/Library/Application Support/io.darkbloom.cluster.service-status.json, read only and never locked or written. Its fields (serving,pairRunning,servicePID) are the wire format since 0.10.9. A status older than two minutes doesn't count, so for up to two minutes after production's service stopped for good, DevNet still waits.darkbloom start/serve, and the cluster service's own solo part). Production's single-Mac serving holds a DevNet pair back through the process rule, but DevNet's single-Mac serving isn't held back by production's pair. TheClusterWorkerOwnerService.serve/serveConfiguredoverloads take no machine lock; no provider code calls them.cluster link --removeasks before taking a port another app still holds, but at a terminal the person can still say yes. The app uninstalled last undoes the setup fully if it adopted it, which itsclusterdoes when it uses the cable on that Mac. An app that never used the cable there removes only Darkbloom's network service.ClusterService.modelLoaded, the update cycle'spairRunsHere) see the other app's worker, so production's pair update can wait while DevNet's pair holds the Mac. This fails safe.~/.darkbloom/cluster/incidents.dev.jsonstays.ClusterConfigurationChecks,ClusterConsoleChecksandClusterDiagnosticsChecksrunners already fail ondev: their source lists missClusterPublicModels,ClusterApprovalFallbackandGLM5NextGPULimitEligibility. They are not in CI.CHANGELOG.md's 0.10.9 known limitation is left to release preparation. The fragmentchangelog.d/cluster-devnet-production-separate-pairs.mdsays it ends, and describes the review and re-review fixes.Refactor pass
A separate, read-only reviewer session (
opencode run --agent refactor-pass, Claude Opus 5.5) reviewed the first commit. Verdict: production is pinned and unchanged, and each build touches only its own jobs. It raised 1 must-fix and 5 should-fix findings, all addressed in081f108031:ClusterUserPaths.init()is for the running build only.cluster pairhint names this build's command.ClusterIncidentLog.filesremoved.Re-review fixes (
350e24789a)The final re-review found two gaps in the GPU lock. Both are fixed red-first (table above):
.failingset-aside cleared. This works both ways.Also from the review's should-fixes:
agent-setup.mdnow has a STOP item for this.userDatafolder.Review fixes (
acb63c5e8a)The independent review (provisional "changes needed") found three issues, each fixed red-first (table above):
darkbloom-dev cluster link --removebeside production. It names production and asks, and refuses without a terminal.Also answered: unchanged
devfails the same 47 DevNet-flavour tests (see Validation).